<template>
  <div class="ruleList">
    <div class="sliding">
      <div class="sliding-mask" v-show="showSlide"
           :class="{'fade-enter-active': enter, 'fade-leave-active': leave}"></div>
      <article class="slide-pop" v-show="showSlide" :class="{'slide-enter-active': enter, 'slide-leave-active': leave}">
        <span class="close" @click="hideSlide">
          <i class="iconfont icon-close_circle_line"></i>
        </span>
        <div class="slide-hd after-bd-b">
          投保规则
        </div>
        <div class="slide-bd" style="overflow-y: auto;">
          <div class="terms-container">
            <ul class="listview-wrap terms-list">
              <li class="after-bd-b" v-for="(item, index) in ruleData" :key="index">
                <div class="link cell-box" @click="showRule(item.pid)">
                  <div class="info-wrap">
                    <div class="info">
                      <h4>
                        <span class="name">{{item.pName}}</span>
                        <i class="iconfont icon-arrows_right icon-right"></i>
                      </h4>
                    </div>
                  </div>
                </div>
                <!--<div class="liabilities-pic" v-if="item.show">-->
                <!--<div class="original-link">-->
                <!--<a :title="item.pName" :href="item.pName !== '定期重大疾病险' ? '/controller/fileCorrelation/pdfPreview?fileName=Rate'+ item.pid +'.pdf' : '/controller/fileCorrelation/pdfPreview?fileName=P0016.pdf'">-->
                <!--<h6>条款预览</h6>-->
                <!--<div class="view assert-r">查看条款原文</div>-->
                <!--</a>-->
                <!--</div>-->
                <!--<div class="liab-img">-->
                <!--<img :src="item.pName !== '定期重大疾病险' ? '/controller/fileCorrelation/imageDownload?fileName=' + item.pid + '.jpg' : '/controller/fileCorrelation/imageDownload?fileName=P0016.jpg'">-->
                <!--</div>-->
                <!--</div>-->
              </li>
            </ul>
          </div>
        </div>
      </article>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ruleList',
  props: ['show', 'data'],
  data () {
    return {
      enter: false,
      leave: false,
      showSlide: false,
      ruleData: null
    }
  },
  methods: {
    hideSlide () {
      this.$emit('ruleStatus', !this.show)
    },
    showRule (pid) {
      if (pid !== 'InsureAll') {
        window.location.href = '/controller/fileCorrelation/pdfPreview?fileName=Insure' + pid + '.pdf'
      } else {
        window.location.href = '/controller/fileCorrelation/pdfPreview?fileName=InsureAll.pdf'
      }
    }
  },
  watch: {
    show (val) {
      if (val) {
        this.enter = true
        this.showSlide = val
        document.body.style.position = 'fixed'
        setTimeout(() => {
          this.enter = false
        }, 500)
      } else {
        this.leave = true
        document.body.style.position = ''
        setTimeout(() => {
          this.showSlide = val
          this.leave = false
        }, 200)
      }
    },
    data (val) {
      this.ruleData = [{
        pName: '投保总则',
        pid: 'InsureAll'
      }]
      this.ruleData = [...this.ruleData, ...val]
    }
  }
}
</script>

<style scoped>
  .sliding {
    position: fixed;
    z-index: 999;
  }

  * {
    padding: 0;
    margin: 0;
  }

  *, :after, :before {
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }

  article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display: block;
  }

  .sliding-mask {
    top: 0;
    z-index: 1000;
    height: 100%;
    background: rgba(0, 0, 0, .6);
    transform-style: preserve-3d;
  }

  .slide-pop, .sliding-mask {
    position: fixed;
    left: 0;
    width: 100%;
    backface-visibility: hidden;
  }

  .slide-pop, .sliding-mask {
    position: fixed;
    left: 0;
    width: 100%;
    backface-visibility: hidden;
  }

  .slide-pop {
    z-index: 1001;
    top: 10%;
    bottom: 0;
    background-color: #fff;
  }

  .slide-pop .close {
    z-index: 1001;
    position: absolute;
    right: 0;
    top: 0;
    width: 45px;
    height: 45px;
    line-height: 45px;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
  }

  .slide-pop .close {
    top: -45px !important;
    color: #fff !important;
  }

  .iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .slide-pop .close i {
    font-size: 24px;
  }

  .slide-pop .slide-bd {
    height: 100%;
    border-top: 45px solid #fff;
    font-size: 13px;
    line-height: 20px;
  }

  .slide-pop .slide-notitle {
    border-top: 0;
  }

  .disease-type {
    color: #333;
    background-color: #fff;
  }

  .after-bd-b, .after-bd-r {
    position: relative;
  }

  .slide-enter-active {
    animation: fadeInUp .3s
  }

  .slide-leave-active {
    animation: fadeInDown .3s
  }

  .fade-enter-active {
    animation: fadeIn .5s
  }

  .fade-leave-active {
    animation: fadeOut .5s
  }

  @keyframes fadeOut {
    0% {
      opacity: 1
    }
    to {
      opacity: 0
    }
  }

  @keyframes fadeIn {
    0% {
      opacity: 0
    }
    to {
      opacity: 1
    }
  }

  @keyframes fadeInDown {
    0% {
      opacity: 1;
      transform: none
    }
    to {
      opacity: 0;
      transform: translate3d(0, 100%, 0)
    }
  }

  @keyframes fadeInUp {
    0% {
      opacity: 0;
      transform: translate3d(0, 100%, 0)
    }
    to {
      opacity: 1;
      transform: none
    }
  }

  .slide-pop .slide-hd {
    z-index: 1;
    left: 0;
    top: 0;
    position: absolute;
    width: 100%;
    height: 45px;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    line-height: 45px;
  }

  .slide-pop .slide-bd {
    height: 100%;
    border-top: 45px solid #fff;
    font-size: 13px;
    line-height: 20px;
  }

  ol, ul {
    list-style: none;
  }

  .terms-list > li {
    overflow: hidden;
  }

  .terms-list .link {
    width: 100%;
    padding-right: 15px;
    display: block;
    overflow: hidden;
  }

  .cell-box {
    display: flex;
    width: 100%;
  }

  .terms-list .pre-wrap {
    width: 65px;
    height: 48px;
    float: left;
    -webkit-box-flex: 1;
    display: -webkit-box;
    -webkit-box-align: center;
  }

  .terms-list .pre {
    position: relative;
    width: 65px;
    height: 50px;
    padding-left: 15px;
    line-height: 48px;
    font-size: 14px;
    color: #999;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .terms-list .info-wrap {
    position: relative;
    width: 100%;
    padding-left: 0px;
  }

  .terms-list .info {
    position: relative;
    width: 100%;
    padding: 11px 15px 11px 15px;
  }

  .terms-list .info h4 {
    position: relative;
    width: 100%;
    display: block;
    overflow: hidden;
    padding-right: 10px;
    font-size: 14px;
    color: #333;
    font-weight: 400;
    line-height: 26px;
  }

  .assert-b:after, .assert-l:after, .assert-r:after, .assert-t:after {
    position: absolute;
    top: 50%;
    right: 0;
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border-style: solid;
    border-color: #717171;
    content: "";
    font-size: 0;
    -webkit-transform: matrix(.71, .71, -.71, .71, 0, 0);
    transform: matrix(.71, .71, -.71, .71, 0, 0);
  }

  .assert-t:after {
    border-width: 1px 0 0 1px;
  }

  .terms-list .liabilities-pic {
    padding: 0 15px 15px;
  }

  .terms-list .original-link > a {
    display: block;
    overflow: hidden;
    color: #999;
    font-size: 13px;
  }

  :link, :visited {
    text-decoration: none;
  }

  a {
    -webkit-tap-highlight-color: transparent;
  }

  .terms-list .liabilities-pic .liab-img {
    position: relative;
  }

  .terms-list .liabilities-pic .liab-img > img {
    width: 100%;
    vertical-align: middle;
  }

  .terms-list .original-link .view:after {
    width: 8px;
    height: 8px;
    right: 3px;
    margin-top: -3px;
    border-color: #ccc;
  }

  .assert-r:after {
    border-width: 1px 1px 0 0;
  }

  .assert-b:after {
    border-width: 0 1px 1px 0;
  }

  .terms-list .original-link .view {
    position: relative;
    width: 100%;
    padding-left: 52px;
    padding-right: 18px;
    text-align: right;
    line-height: 46px;
  }

  .terms-list .original-link h6 {
    float: left;
    width: 52px;
    height: 46px;
    line-height: 46px;
  }

  .icon-right {
    float: right;
    font-size: 14px;
  }
</style>
